﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DataObject.DataAccess;

public partial class Pages_Operators_RouteList : System.Web.UI.Page
{
    private object _routeList = null;
    public object RouteList
    {
        get
        {
            if (_routeList == null)
            {
                _routeList = (HttpContext.Current.Cache["RouteList"] as List<object>);
                if (_routeList == null)
                {
                    _routeList = RouteDAO.CreateInstant().GetAllRoutes();
                    HttpContext.Current.Cache.Insert("RouteList", _routeList);
                }
            }
            return _routeList;
        }
        set
        {
            HttpContext.Current.Cache.Insert("RouteList", _routeList);
        }
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            // Load route list
            this.ddlRoute.DataSource = RouteList;
            this.ddlRoute.DataTextField = "RouteCode";
            this.ddlRoute.DataValueField = "RouteCode";
            this.ddlRoute.DataBind();
        }
    }
}
